# -*- mode: makefile -*

packages.rec:
	./build-aux/list-packages.sh `pwd` \
          | recsel --sort=name \
          | sed 's/ *$$//' >$@.tmp
	mv $@.tmp $@
.PHONY: packages.rec

.pkg.tmpl: Makefile
	echo '- [{{name}}@{{version}}]({{homepage}}) - {{synopsis}}' >$@

packages.txt: packages.rec .pkg.tmpl
	recfmt -f .pkg.tmpl <$< >$@.tmp
	mv $@.tmp $@

README.md: build-aux/README.m4 packages.txt
	m4 $< >$@.tmp
	mv $@.tmp $@

help:
	@echo "Useful targets:"
	@echo "- README.md   : Update package list"
	@echo "- check	     : run tests, currently runs linters"
	@echo "- build-check : check that packages build"
:PHONY: help

all: help

# Run lints on all packages
check: packages.rec
	guix lint -L `pwd` `recfmt "{{name}}@{{version}} " <packages.rec`

# Check that every package builds
build-check: packages.rec
	guix build -L `pwd` -k `recfmt "{{name}}@{{version}} " <packages.rec`
